package org.lanqiao.api.admin;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.common.Constants;
import org.lanqiao.common.JsonResult;
import org.lanqiao.common.JsonResultWriter;
import org.lanqiao.pojo.PageModel;
import org.lanqiao.service.AdminServiceImpl;

/**
 * 分页查询语句
 */
@WebServlet("/api/admin/PageUserServlet")
public class PageUserServlet extends HttpServlet {
	
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
	
	String pageSize="10";
	String pageNum=request.getParameter("page");
	
	/**
	 * 调用查询用户
	 */
	AdminServiceImpl abc=new AdminServiceImpl();
	JsonResult result=null;
	try {
		PageModel<List> model=abc.pagingUsers(pageNum, pageSize);
		if(model!=null){
			result=new JsonResult("查询成功",Constants.STATUS_SUCCESS,model);
		}else {
			result=new JsonResult("查询错误",Constants.STATUS_UNFOUND);
		}
	} catch (Exception e) {
		result=new JsonResult("查询异常",Constants.STATUS_FAILURE);
	}
	JsonResultWriter.writer(response, result);
}


}
